﻿using ProjectAutumn;
using ProjectAutumn.Graphics;

namespace Test_Project
{
    class TestGame : Game
    {
        private Texture fileTestTexture;
        private Texture dynamicTexture;
        private GraphicCapabilities capabilities;
        public override void Initialize()
        {
            capabilities = GraphicsDevice.GraphicCapabilities;
            if (!capabilities.SupportsDrawing2D) return;
            if (capabilities.SupportsLoadingTextureFile)
                fileTestTexture = Texture.FromFile(GraphicsDevice, "Lenna.png");
            if(!capabilities.SupportsDynamicTextures) return;
            dynamicTexture = GraphicsDevice.CreateTexture(64, 64);
            if(!capabilities.SupportsTextureSetData) return;
            Color[] colorData = new Color[64 * 64];
            for(int i = 0; i < colorData.Length; i++)
                colorData[i] = Color.Green;
            dynamicTexture.SetData(colorData);
        }
        public override void Draw(GameTime gameTime)
        {
            if (!capabilities.SupportsClearing) return;
            GraphicsDevice.Clear(Color.CornflowerBlue);
            if (!capabilities.SupportsDrawing2D) return;
            GraphicsDevice.Begin2D();
            if (capabilities.SupportsLoadingTextureFile)
                GraphicsDevice.Draw(fileTestTexture, Vector2.Zero, Color.White);
            if (capabilities.SupportsDynamicTextures)
                GraphicsDevice.Draw(dynamicTexture, new Vector2(736, 0), Color.White);
            GraphicsDevice.End2D();
        }
    }
}
